package com.bx.thymeleafdemo.service.serviceImp;


import com.bx.thymeleafdemo.model.User;
import com.bx.thymeleafdemo.service.UserService;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Repository
public class UserServiceImpl implements UserService {
    private List<User> users;

    public UserServiceImpl() {
        users = new ArrayList<User>(10);
        users.add(new User(1, "yitian", 24, LocalDate.now()));
        users.add(new User(2, "zhang3", 22, LocalDate.now()));
        users.add(new User(3, "li4", 25, LocalDate.now()));
        users.add(new User(4, "leo", 26, LocalDate.of(1995, 7, 3)));
    }

    @Override
    public List<User> getAll() {
        return users;
    }

    @Override
    public void add(User user) {
        users.add(user);
    }
}
